package com.smallrig.mall.template.builder;

public class TestBuilder {

    public static void main(String[] args) {

        User user = Builder.builder(User::new)
                .with(User::setUsername, "lry")
                .with(User::setAge, 26)
                .build();

        System.out.println(user);
    }

    static class User{
        private String username;
        private int age;

        public void setAge(int age) {
            this.age = age;
        }

        public int getAge() {
            return age;
        }

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }

        @Override
        public String toString() {
            return "User{" +
                    "username='" + username + '\'' +
                    ", age=" + age +
                    '}';
        }
    }
}
